package ar.com.juanlopezcervero.flexigrid4j.params;

import java.io.Serializable;

import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;

public class FlexigridColumn extends FlexigridItem implements Serializable {
	
	private static final long serialVersionUID = -3530780779591296486L;

	//	 {display: 'Column Title', name : 'row.atribute.name', width : 80, sortable : false, align: 'left'}
	
	private String display;
	private String name;
	private Integer width;
	private Boolean sortable;
	private String align;
	
	public FlexigridColumn() {
		super();
	}
	
	/**
	 * Ejemplo:
	 * {display: 'Column Title', name : 'row.atribute.name', width : 80, sortable : false, align: 'left'}
	 * @param display
	 * @param name
	 * @param width
	 * @param sortable
	 * @param align
	 */
	public FlexigridColumn(String display, String name, Integer width, Boolean sortable, String align) {
		this.display = display;
		this.name = name;
		this.width = width;
		this.sortable = sortable;
		this.align = align;
	}
	
	@Override
	public JSONObject getJSONObejct() throws JSONException {
		JSONObject jsonObject = new JSONObject();
		jsonObject.putOpt("display", display);
		jsonObject.putOpt("name", name);
		jsonObject.putOpt("width", width);
		jsonObject.putOpt("sortable", sortable);
		jsonObject.putOpt("align", align);
		return jsonObject;
	}
	
	
	
	public String getDisplay() {
		return display;
	}
	
	/**
	 * Column title
	 * @param display
	 */
	public void setDisplay(String display) {
		this.display = display;
	}
	public String getName() {
		return name;
	}
	
	/**
	 * Atribute name
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	public Integer getWidth() {
		return width;
	}
	
	/**
	 * Width in px
	 * @param width
	 */
	public void setWidth(Integer width) {
		this.width = width;
	}
	public Boolean getSortable() {
		return sortable;
	}
	
	/**
	 * Enable/Disable sort
	 * @param sortable
	 */
	public void setSortable(Boolean sortable) {
		this.sortable = sortable;
	}
	public String getAlign() {
		return align;
	}
	
	/**
	 * Text align
	 * @param align
	 */
	public void setAlign(String align) {
		this.align = align;
	}
	
}
